

namespace Stee.CAP8.MessageBus.Interfaces.Models
{
    using System;

    /// <summary>
    /// Kafka configuration entry value & meta-data
    /// </summary>
    public class ConfigurationEntry
    {
        /// <summary>
        /// Gets the configuration name
        /// </summary>
        public string Name { get; }

        /// <summary>
        /// Gets the configuration value
        /// </summary>
        public string Value { get; }

        /// <summary>
        /// Gets whether or not the config value is the default or was explicitly set
        /// </summary>
        public bool IsDefault { get; }

        /// <summary>
        /// Gets whether or not the config is read-only (cannot be updated)
        /// </summary>
        public bool IsReadOnly { get; }

        /// <summary>
        /// Gets whether or not the config value is sensitive
        /// </summary>
        public bool IsSensitive { get; }


        /// <summary>
        /// Initializes a new instance of the ConfigurationProperty class
        /// </summary>
        /// <param name="name">Configuration name</param>
        /// <param name="value">Configuration value</param>
        /// <param name="isDefault">Whether or not the config value is the default or was explicitly set.</param>
        /// <param name="isReadOnly">Whether or not the config is read-only (cannot be updated).</param>
        /// <param name="isSensitive">Whether or not the config value is sensitive.
        /// The value for sensitive configuration values is always returned as null.</param>
        public ConfigurationEntry(string name, string value, bool isDefault, bool isReadOnly, bool isSensitive)
        {
            var nm = name?.Trim();

            if (string.IsNullOrEmpty(nm))
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.Name = name;
            this.Value = value;
            this.IsDefault = isDefault;
            this.IsReadOnly = isReadOnly;
            this.IsSensitive = isSensitive;
        }
    }
}
